package com.lc.rongzecaifu.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lc.rongzecaifu.MyApplication;
import com.lc.rongzecaifu.conn.JsonBorrowout;
import com.lc.rongzecaifu.rongzecaifu.R;
import com.zcx.helper.bound.BoundViewHelper;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;


/**
 * Created by Administrator on 4/13/2016.
 */
public class OutDataAdapter extends RecyclerView.Adapter<OutDataAdapter.ViewHolder> {


    private Context context;
    private List<JsonBorrowout.Info.ListContent> list;


    public OutDataAdapter(Context context, List<JsonBorrowout.Info.ListContent> list) {
        this.context = context;
        this.list = list;

    }


    public static class ViewHolder extends RecyclerView.ViewHolder {


        @Bind(R.id.tv_02)
        TextView tv_02;

        @Bind(R.id.tv_03)
        TextView tv_03;
        @Bind(R.id.progress)
        TextView progress;

        @Bind(R.id.money)
        TextView money;
        @Bind(R.id.tv_time)
        TextView tv_time;

        @Bind(R.id.yihuanjine)
        TextView yihuanjine;

        //逾期天数

        @Bind(R.id.tv_timeUnit)
        TextView tv_timeUnit;

        @Bind(R.id.tv_money)
        TextView tv_money;

        @Bind(R.id.textView13)
        TextView textView13;

        //待付总金额
        @Bind(R.id.tv_already_money)
        TextView tv_already_money;

        @Bind(R.id.text_all)
        TextView text_all;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }


    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = BoundViewHelper.boundView(this, MyApplication.scaleScreenHelper.loadView((ViewGroup) LayoutInflater.from(parent.getContext())
                .inflate(R.layout.item_borrowing_outdata, null)));
        // set the view's size, margins, paddings and layout parameters
        OutDataAdapter.ViewHolder vh = new OutDataAdapter.ViewHolder(view);

        return vh;

    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.tv_02.setText(list.get(position).borrow_name);
        holder.tv_03.setText(list.get(position).repayment_type_cn);


        holder.progress.setText(list.get(position).expired_money);
        holder.textView13.setText(list.get(position).capital + "/");
        holder.money.setText(list.get(position).interest);
        holder.tv_time.setText(list.get(position).deadline);


        holder.yihuanjine.setText(list.get(position).sort_order+"期/");


        holder.tv_timeUnit.setText(list.get(position).breakday + list.get(position).borrow_duration_cn);

//待付催收费

        holder.tv_money.setText(list.get(position).call_fee);
        //待付总金额
        holder.tv_already_money.setText(list.get(position).allneed);
        //应还日期
        holder.text_all.setText(list.get(position).total + "期");
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
}
